/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff4444;
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background: #44ff44;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* 主体布局 */
.main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1rem;
    padding: 1rem;
}

@media (max-width: 768px) {
    .main {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
    }
}

/* 聊天容器 */
.chat-container {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 1rem;
    height: 500px;
    overflow-y: auto;
    border-bottom: 1px solid #eee;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

/* 消息样式 */
.message {
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    max-width: 80%;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    word-wrap: break-word;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.ai-message .message-content {
    background: #f5f5f5;
    color: #333;
    margin-right: auto;
    border-bottom-left-radius: 5px;
    border-left: 3px solid #4CAF50;
}

.system-message .message-content {
    background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
    color: #2d3436;
    margin: 0 auto;
    text-align: center;
    border-radius: 10px;
}

.system-message ul {
    text-align: left;
    margin-top: 0.5rem;
    padding-left: 1.5rem;
}

/* 输入区域 */
.input-container {
    padding: 1rem;
    background: #fafafa;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#messageInput {
    flex: 1;
    padding: 0.8rem 1rem;
    border: 2px solid #ddd;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

#messageInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-button {
    padding: 0.8rem 1.5rem;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.send-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 控制面板 */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.settings {
    flex: 1;
}

.settings summary {
    padding: 0.5rem;
    background: #e3f2fd;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.settings summary:hover {
    background: #bbdefb;
}

.settings-content {
    margin-top: 0.5rem;
    padding: 1rem;
    background: white;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.setting-group label {
    width: 80px;
    font-weight: 500;
}

.setting-group input[type="range"] {
    flex: 1;
}

.setting-group span {
    min-width: 30px;
    text-align: center;
    font-weight: bold;
    color: #667eea;
}

.clear-button {
    padding: 0.5rem 1rem;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.clear-button:hover {
    background: #ff5252;
}

/* 侧边栏 */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.model-info, .api-status, .quick-actions {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.model-info h3, .api-status h3, .quick-actions h3 {
    margin-bottom: 0.8rem;
    color: #333;
    font-size: 1rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.3rem;
}

.info-content {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #666;
}

.info-content p {
    margin-bottom: 0.3rem;
}

.action-button {
    display: block;
    width: 100%;
    padding: 0.6rem;
    margin-bottom: 0.5rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s, transform 0.2s;
}

.action-button:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.action-button:last-child {
    margin-bottom: 0;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 1rem;
    background: #333;
    color: white;
    font-size: 0.85rem;
}

/* 加载覆盖层 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        margin: 0;
        border-radius: 0;
    }
    
    .header {
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .chat-messages {
        height: 400px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sidebar {
        order: -1;
    }
    
    .message-content {
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .input-group {
        flex-direction: column;
    }
    
    .send-button {
        align-self: stretch;
        justify-content: center;
    }
}